package com.ziqing.apeletnews.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ziqing.apeletnews.R;
import com.ziqing.apeletnews.adapter.ArticleAdapter;
import com.ziqing.apeletnews.base.BaseFragment;
import com.ziqing.apeletnews.bean.ArticleBean;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by WT on 2018/4/12.
 */

public class ArticleFragment extends BaseFragment {

    @BindView(R.id.rv_article)
    RecyclerView rvArticle;
    Unbinder unbinder;
    private ArticleAdapter adapter;
    private List<ArticleBean> data = new ArrayList<>();
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_article, container, false);
        unbinder = ButterKnife.bind(this, view);
        data.add(new ArticleBean("","","https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523634228476&di=e976c74deefd88dcb515db98415f3cde&imgtype=0&src=http%3A%2F%2Fimage001.server110.com%2F20170322%2F98a96ca05f6e32b15f3c2d0d46e5d051.gif"
                ,"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523634228476&di=e976c74deefd88dcb515db98415f3cde&imgtype=0&src=http%3A%2F%2Fimage001.server110.com%2F20170322%2F98a96ca05f6e32b15f3c2d0d46e5d051.gif",0));
        data.add(new ArticleBean("","","https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523634228476&di=e976c74deefd88dcb515db98415f3cde&imgtype=0&src=http%3A%2F%2Fimage001.server110.com%2F20170322%2F98a96ca05f6e32b15f3c2d0d46e5d051.gif"
                ,"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523634228476&di=e976c74deefd88dcb515db98415f3cde&imgtype=0&src=http%3A%2F%2Fimage001.server110.com%2F20170322%2F98a96ca05f6e32b15f3c2d0d46e5d051.gif",1));
        data.add(new ArticleBean("","","https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523634228476&di=e976c74deefd88dcb515db98415f3cde&imgtype=0&src=http%3A%2F%2Fimage001.server110.com%2F20170322%2F98a96ca05f6e32b15f3c2d0d46e5d051.gif"
                ,"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523634228476&di=e976c74deefd88dcb515db98415f3cde&imgtype=0&src=http%3A%2F%2Fimage001.server110.com%2F20170322%2F98a96ca05f6e32b15f3c2d0d46e5d051.gif",1));
        data.add(new ArticleBean("","","https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523634228476&di=e976c74deefd88dcb515db98415f3cde&imgtype=0&src=http%3A%2F%2Fimage001.server110.com%2F20170322%2F98a96ca05f6e32b15f3c2d0d46e5d051.gif"
                ,"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1523634228476&di=e976c74deefd88dcb515db98415f3cde&imgtype=0&src=http%3A%2F%2Fimage001.server110.com%2F20170322%2F98a96ca05f6e32b15f3c2d0d46e5d051.gif",0));

        rvArticle.setLayoutManager(new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false));
        adapter = new ArticleAdapter(data,getContext());
        rvArticle.setAdapter(adapter);
        adapter.notifyDataSetChanged();
        rvArticle.setHasFixedSize(true);
        rvArticle.setFocusable(false);
        rvArticle.setNestedScrollingEnabled(false);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
